﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Forums.aspx.cs" Inherits="NEWS.Admin.Forums" %>
<%@ Register Assembly="msgBox" Namespace="BunnyBear" TagPrefix="cc1" %>
<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript" >
        function confirmAction()
        {
            if(confirm("Bạn có chắc chắn muốn xóa!"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    </script>
    <script type="text/javascript">
        function SelectAll(CheckBox)
        {
            TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
            var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
            var TargetChildControl = "chkSelect";   
            var Inputs = TargetBaseControl.getElementsByTagName("input");
            for(var iCount = 0; iCount < Inputs.length; ++iCount)
            {                
                if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0)
                    Inputs[iCount].checked = CheckBox.checked;   
            }
        }
        function SelectDeSelectHeader(CheckBox)
        {        
            TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
            var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
            var TargetChildControl = "chkSelect";   
            var TargetHeaderControl = "chkSelectAll";   
            var Inputs = TargetBaseControl.getElementsByTagName("input");
            var flag = false;
            var HeaderCheckBox;
            for(var iCount = 0; iCount < Inputs.length ; ++iCount)
            {    
                if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetHeaderControl,0) >= 0)            
                    HeaderCheckBox = Inputs[iCount];            
                if(Inputs[iCount] != CheckBox && Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0 && Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)
                {            
                    if(CheckBox.checked)
                    {                    
                        if(!Inputs[iCount].checked)                    
                        {                    
                            flag = false;
                            HeaderCheckBox.checked = false;                       
                            return;
                        }
                        else
                            flag = true;                    
                    }
                    else if(!CheckBox.checked)                
                        HeaderCheckBox.checked = false;                                                       
                }            
            }                      
            if(flag)        
                HeaderCheckBox.checked = CheckBox.checked        
        }
    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
        <ContentTemplate>
            <asp:Panel ID="PanelDasboard" runat="server" Visible="true" >
                <div class="dashboard">
                    <h2 class="ico_mug">Quản lý diễn đàn</h2>
                    <div style="width:100%; margin-bottom:10px;">
                        <p style="margin-right:10px;float:left;">
                            &nbsp;</p>
                        <p>
                            <asp:Label ID="lbldanhmuctin" runat="server" Text="Chuyên mục: "></asp:Label>
                            <asp:DropDownList Width="150px" ID="dldanhmuctin" runat="server" AutoPostBack="true" Visible="true"
                                DataTextField="Value" DataValueField="Key" 
                                onselectedindexchanged="dldanhmuctin_SelectedIndexChanged">
                            </asp:DropDownList>
                            <asp:Label class="forum_chudecon" ID="lbldanhmuccon" runat="server" Text="Chủ đề: "></asp:Label>
                            <asp:DropDownList Width="150px" ID="dldanhmuccon" runat="server" 
                                AutoPostBack="true" Visible="true"
                                DataTextField="Value" DataValueField="Key" 
                                onselectedindexchanged="dldanhmuccon_SelectedIndexChanged">
                            </asp:DropDownList>
                        </p>
                        <p style="margin-right:10px; float:left">
                                <asp:LinkButton ID="lbtdangchude" 
                                runat="server" Font-Bold="True" ForeColor="Blue" Visible="true" 
                                    onclick="lbtdangchude_Click">Đăng chủ đề
                                </asp:LinkButton>
                        </p>
                        <p style="margin-right:10px;float:left;">
                                <asp:LinkButton ID="btndangtin" 
                                runat="server" Font-Bold="True" ForeColor="Blue" Visible="true" 
                                onclick="btndangtin_Click">Đăng bài viết
                                </asp:LinkButton>
                        </p>
                        <p style="margin-right:10px;">
                                <asp:LinkButton ID="btnxoatin" runat="server" Font-Bold="True" ForeColor="Blue" 
                                Visible="true" onclick="btnxoatin_Click" OnClientClick="javascript:return confirmAction();">Xóa 
                                Tin Được Chọn
                                </asp:LinkButton>
                        </p>
                    </div>
                    <div>
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                            CellPadding="4" DataKeyNames="ForumNewID" Width="100%" 
                            onselectedindexchanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                            ForeColor="#333333" GridLines="None" 
                            onrowdatabound="GridView1_RowDataBound" 
                            onrowcommand="GridView1_RowCommand">
                            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                            <RowStyle BackColor="#EFF3FB" />
                            <Columns>
                                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Admin/img/edit.png" 
                                    ShowSelectButton="True" >
                                    <ItemStyle Width="30px" />
                                </asp:CommandField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtxemtin" runat="server" CausesValidation="False">Xem</asp:LinkButton>
                                    </ItemTemplate>
                                    <ItemStyle Width="30px" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkSelect" runat="server" />
                                    </ItemTemplate>
                                    <HeaderTemplate>
                                     <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this);" />                                
                                    </HeaderTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle Width="30px" HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="ForumNewID" HeaderText="Mã tin" ReadOnly="True" 
                                    SortExpression="ForumNewID" InsertVisible="False" >
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" Width="45px" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="Tiêu đề">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtlinktitle" runat="server" CommandName="linktitile" 
                                            Text='<%# Eval("Title") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="CategoryName" HeaderText="Tên danh mục" 
                                    SortExpression="CategoryName" >
                                    <HeaderStyle HorizontalAlign="Left" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </asp:BoundField>
                                <asp:BoundField DataField="UserName" HeaderText="Người gửi" 
                                    SortExpression="UserName" FooterText=" " >
                                    <HeaderStyle HorizontalAlign="Left" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </asp:BoundField>
                                <asp:BoundField DataField="CreatedDate" HeaderText="Ngày đăng" 
                                    SortExpression="CreatedDate" DataFormatString="{0:dd/MM/yyyy}">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="SubTopicForumID" />
                            </Columns>
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                            SelectMethod="GetAllForumNewsBOList" 
                            TypeName="HousingInfo.Library.ForumNewsBOList">
                        </asp:ObjectDataSource>
                        <asp:Label ID="messagedelete" runat="server" Font-Bold="True" Font-Size="Small" 
                            ForeColor="Red"></asp:Label>
                        <br />
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
